import React, { Component } from 'react'
import { Form, Input, Button, Checkbox } from 'antd';
import "../static/css/sign.css"


export default  class sign extends Component{
    constructor(props){
        super(props)
        this.state = {
            selectedTab: 'blueTab',
            hidden: false,
            fullScreen: false,
        }
    }

    render(){
        const layout = {
            labelCol: {
                span: 8,
            },
            wrapperCol: {
                span: 16,
            },
        };
        const tailLayout = {
            wrapperCol: {
                offset: 8,
                span: 16,
            },
        };
        const onFinish = values => {
            console.log('Success:', values);
            if(values.name == "admin" && values.pasword == "admin"){
                this.props.history.push("/sidebar/home")
            }else{
                alert("密码不正确")
            }
        };

        const onFinishFailed = errorInfo => {
            console.log('Failed:', errorInfo);
            alert("请输入用户信息")
        };
        return (
            <div className="signbox">
                <Form
                    className="sign"
                    {...layout}
                    name="basic"
                    initialValues={{
                        remember: true,
                    }}
                    onFinish={onFinish}
                    onFinishFailed={onFinishFailed}
                >
                    <div className="namesign">管理员登录</div>
                    <Form.Item
                        label="账户"
                        name="name"
                        rules={[
                            {
                                required: true,
                                message: '请输入用户名',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="密码"
                        name="pasword"
                        rules={[
                            {
                                required: true,
                                message: '请输入密码',
                            },
                        ]}
                    >
                        <Input.Password />
                    </Form.Item>

                    <Form.Item {...tailLayout} name="remember" valuePropName="checked">
                        <Checkbox>记住密码</Checkbox>
                    </Form.Item>

                    <Form.Item {...tailLayout}>
                        <Button type="primary" htmlType="submit">
                            登录
                        </Button>
                    </Form.Item>
                </Form>

            </div>
        )
    }

}
